package sk.stuba.fiit.ltasys.ws.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ws.server.endpoint.annotation.Endpoint;
import org.springframework.ws.server.endpoint.annotation.PayloadRoot;

import sk.stuba.fiit.ltasys.web.mvc.model.service.ArchiveService;
import sk.stuba.fiit.ltasys.ws.schema.beans.ArchiveRequest;
import sk.stuba.fiit.ltasys.ws.schema.beans.ArchiveResponse;
import sk.stuba.fiit.ltasys.ws.service.MarshalingArchiveService;


@Endpoint
public class ArchiveEndpoint implements MarshalingArchiveService {

	@Autowired
	ArchiveService archiveService;
	
	 @PayloadRoot(localPart=ARCHIVE_REQUEST, namespace=NAMESPACE)
		public ArchiveResponse processArchiveReqest(ArchiveRequest request) {
		 ArchiveResponse response = new ArchiveResponse();
		 
		 if(!archiveService.verifyUser(request.getUser())){
		 	response.setStatus(INCORECT_USERNAME_OR_PASSWORD);
		 	return response;
		 }
		
		 response = archiveService.processArchiveRequest(request);
		 return response;
	}
}
